package healthwatcher.storage;

import healthwatcher.ConfigurationHandler;
import healthwatcher.Constants;
import healthwatcher.ConfigurationHandler.Features;
import healthwatcher.cc.storage.StorageAWS;
import healthwatcher.cc.storage.StorageHP;

import java.io.File;
import java.util.Properties;
import java.util.logging.Level;

import lib.logging.LogMechanism;

import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.InputStreamMap;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;

import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.PutObjectRequest;

public class Storage {
	public void storePhoto(String code, File photo){
		if (ConfigurationHandler.getInstance().getFeature(Features.STORAGE).equals(ConfigurationHandler.AWSSTORAGE)){
			StorageAWS.store(code, photo);
		}else if(ConfigurationHandler.getInstance().getFeature(Features.STORAGE).equals(ConfigurationHandler.HPSTORAGE)){
			StorageHP.store(code, photo);
		}
	}
	public void storeLog(){
		Properties props=new Properties();
		props.setProperty(KeystoneProperties.CREDENTIAL_TYPE, CredentialTypes.API_ACCESS_KEY_CREDENTIALS);
		
		BlobStoreContext context=ContextBuilder.newBuilder("hpcloud-objectstorage").
				credentials("andregustavoo-tenant1:WU7UC9PHMZR5HCJNX8TA", "tbVCFfpoVTQjRp7YjjJwz0C5lOpI0wrOg0HYptH1").overrides(props).build(BlobStoreContext.class);
		
		InputStreamMap input= context.createInputStreamMap("log");
		
		input.putString("log.txt", LogMechanism.getInstance().getLogger().toString());
		
		context.close();

	}
	
}
